package com.atguigu.lease.admin.controller.system;

import com.atguigu.lease.admin.service.SystemPostService;
import com.atguigu.lease.model.bean.SystemPost;
import com.atguigu.lease.model.result.Response;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Tag(name = "系统岗位管理模块")
@RestController
@RequestMapping("/admin/system/post")
public class SystemPostController {

    @Autowired
    private SystemPostService systemPostService;
    @Operation(summary = "3、新增或更新系统岗位")
    @PostMapping("saveOrUpdate")
    public Response saveOrUpdate(@RequestBody SystemPost systemPost) {
        systemPostService.saveOrUpdate(systemPost);
        return Response.ok(null);
    }

    @Operation(summary = "2、查询所有系统岗位")
    @GetMapping("list")
    public Response<List<SystemPost>> list(){
        return Response.ok(systemPostService.list());
    }

    @Operation(summary = "1、分页查询岗位列表")
    @GetMapping("/page")
    public Response<Page<SystemPost>> page(
            @RequestParam("current")Integer current,
            @RequestParam("size")Integer size
    ){
        Page<SystemPost> page = systemPostService.page(new Page<>(current, size));
        return Response.ok(page);
    }
}
